/**
 * 
 */
package com.block.common.security.util;


import com.alibaba.druid.filter.config.ConfigTools;


/**
 *  
 * 【淘宝】
 * 【RSA】加密工具 
 * 2016年11月30日 下午5:13:21
 */
public class EncriptionKit {
//	private static final Logger log = Logger.getLogger(EncriptionKit.class);
	
	/**
	 * RSA解密
	 * password解密
	 * @param publicKey
	 * @param password
	 * @return
	 * 2016年11月30日 下午5:56:44
	 */
	public static String passwordDecrypt(String publicKey, String password) {
		String result = null;
		try {
			result = ConfigTools.decrypt(publicKey, password);// 解密
		} catch (Exception e) {
//			log.error("【RSA解密密码】出现异常", e);
			e.printStackTrace();
		}
		return result;
	}
	
	/**
	 * RSA加密
	 * password解密
	 * @param publicKey
	 * @param password
	 * @return
	 * 2016年11月30日 下午5:56:44
	 */
	public static String passwordEncrypt(String publicKey, String password) {
		String result = null;
		try {
			result = ConfigTools.encrypt(publicKey, password);
		} catch (Exception e) {
//			log.error("【RSA加密密码】出现异常", e);
			e.printStackTrace();
		}
		return result;
	}
	
	public static void main(String[] args) {
		
		String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCn8CyWKRG2XjiTet4OaWaWtWLLHminmdZ9RXnAR2qiMUkMnm542gPH6/KyXkFtWO2MrupAJzHsKPHJwFk/a2G+IRTh4vWt5PsPk1WyjnDC5/RNbJB2/qf7EsX2mIds6cKZP8GyZrPDXOFY9XbaxZ+CcvvNjthRiOFOPqzYe19SIQIDAQAB";
		String secretKey = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKfwLJYpEbZeOJN63g5pZpa1YsseaKeZ1n1FecBHaqIxSQyebnjaA8fr8rJeQW1Y7Yyu6kAnMewo8cnAWT9rYb4hFOHi9a3k+w+TVbKOcMLn9E1skHb+p/sSxfaYh2zpwpk/wbJms8Nc4Vj1dtrFn4Jy+82O2FGI4U4+rNh7X1IhAgMBAAECgYAGQ+qV65BSmm9H6USRixMdukSmSUskPZQH9miVaNSsmmQcSWjbr16GveG/D88nEjNClV/95rhxFBH5MejiedIao0uE5GPN5ywHnWE7A9rmK87nSpsVSrH6xzXKVClOQ4oSsB/K7/GVnvg0KjLpFwoHHjn6RL2GOriIjieLKTOv8QJBANfQfi4JGqvgq/r9XL0EO65PxwvuUzO5tvM+L/Uf8VgrVa0aT3Nw1ON8zh5cqA8JuAPNP92Gxuq5KVDNYujZ6y0CQQDHNYCCfSPSL8VYYy7cAgrDbLUgaTEc/WYG+GFlJNjFYkKcIax6zD5OEFi/9Hl/f66Oemlj3BE9pSGcggfeqAtFAkEAzPh0Hvz+m+fS75rbDZqLpE6Y2bgMxb/JBtU1bzZbXkYqJTIr65RqXXUXvrZ5125/mvzBf4CWRDCAEQJAwq7WMQJAR2LPy3MGrCJ8SKE6QJLmwoMpIRUxCV9w+Vx2omUi3RDKJ+MVSOf6B8Vp2FfGVj8uEVaif6tz7jBHrCsYoNx9NQJBAMC1NEg+N866Srv+i1STkzvYyF9idTvUpM7kh76ydY2Ojsg/xh6muCE9oGMjO8ePl/zGzv1RSBNmZx9B5Vi4Cvc=";
		System.out.println(passwordEncrypt(secretKey, "walletXiangjiao123"));

		String pwd = "iDecdSsLCumTfZefCIOmpHQbEuLTKJHOhI5fknDO6mzLNXSPRyoLGnwYdAfHQEn9/hT5uNQ5yezA5txqT/WpnAdvoAZZXXPvF139oJW+Nf9bpp2O1W0iq/q3e1UPgT+65FD5HMaA+BcVkxY0G8dCdygns4dgUWppyL/T2Iz1HQo=";
		System.out.println(passwordDecrypt(publicKey, pwd));
	}
	
}
